package com.daoxuehao.baseframework.module.main.presenter;

import com.daoxuehao.baseframework.model.MainModel;
import com.daoxuehao.baseframework.model.beans.IpInfo;
import com.daoxuehao.baseframework.module.IPresenter;
import com.daoxuehao.baseframework.module.main.view.IMainView;

/**
 * Created by Yale on 2016/3/28.
 */
public class MainPresenter implements IPresenter<IMainView>, IMainPresenter {
    private IMainView mMainView;
    private MainModel mMainModel;

    public MainPresenter(IMainView view) {
        attachView(view);
        mMainModel = new MainModel(this);
    }

    @Override
    public void attachView(IMainView view) {
        this.mMainView = view;
    }

    @Override
    public void detachView() {
        this.mMainView = null;
    }

    public void loadData() {
        mMainView.showProgress();
        mMainModel.loadData();
    }


    @Override
    public void loadDataSuccess(IpInfo mainModelBean) {
        mMainView.showData(mainModelBean);
        mMainView.hideProgress();
    }

    @Override
    public void loadDataFailure() {
        mMainView.hideProgress();
    }
}
